<%@ page import="com.edu.dreams.entity.News" %>
<%@ page import="java.util.List" %>
<%@ page import="com.github.pagehelper.PageInfo" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>资讯管理</title>
  <meta name="description" content="一个充满童话世界的地方，带你回味童年." />
  <meta name="keywords" content="童话、英雄和魔法" />
  <link rel="shortcut icon" href="images/favicon.ico" />
  <!-- 引入我们自己的样式文件 -->
    <link rel="stylesheet" type="text/css" href="css/content.css"/>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script>
        function del(nid) {
            if (window.confirm("确认要删除此信息吗?")) {
                window.location.href = "${pageContext.request.contextPath}/deletenews?id=" + nid;
            }
        }
    </script>
</head>

<body>
<div style="padding-left:4px; ">
    <table width="1200" border="0" cellpadding="0" cellspacing="0">
        <tr height="30">
            <td width="270" background="images/title01.jpg" class="title">&gt;&gt;资讯管理</td>
            <td width="30" height="30"><img src="images/title002.gif"/></td>
            <td width="530" bgcolor="#d9f0ff" class="txt">您的位置：后台管理 &gt; 资讯管理 &gt; 资讯信息</td>
        </tr>
    </table>
    <br/>
    <table width="1200" border="0" cellpadding="0" cellspacing="0">
        <tr height="30">
            <td width="270" background="images/title01.jpg" bgcolor="#d9f0ff">
                <div
                        style=" background-color:#d9f0ff; width:130px; height:23px; border-width:1px; border-style:solid; border-color:#CCC; text-align:center; line-height:23px;">
                    <a href="${pageContext.request.contextPath}/addnews" target="main">添加资讯</a>
                </div>
            </td>
        </tr>
    </table>
    <h3>资讯信息列表</h3>
    <table width="1180" border="1" cellpadding="0" cellspacing="0" style="text-align:center; line-height:30px;">
        <tr>
            <th scope="col">资讯名称</th>
            <th scope="col">发表时间</th>
            <th scope="col">资讯来源</th>
            <th scope="col" align="middle">操作</th>
        </tr>
        <%
            for (News n : ((PageInfo<News>) request.getAttribute("news")).getList()) {
                out.print("<tr align='middle'>" +
                        "<td>" + n.getNews_name() + "</td>" +
                        "<td>" + n.getNews_time() + "</td>" +
                        "<td>" + n.getNews_src() + "</td>" +
                        "            <td align='middle'><a href='updateNewsPage?id=" + n.getNews_id() + "'>编辑</a><input type='button' style='margin-left: 40px;' name='bt1' value='删除' onclick=\"del('" + n.getNews_id() + "');\"></td>" +
                        "</tr>");
            }
        %>
    </table>
    <table width="1180" border="0" cellpadding="0" cellspacing="0" style="line-height:50px">
        <tbody>
        <tr>
            <td width="40%">&nbsp;</td>
            <td align="right">
                <a href="${pageContext.request.contextPath}/seenew?startPage=1">首 页</a>
                <c:choose>
                    <c:when test="${news.pageNum-1>0}">
                        <a href="${pageContext.request.contextPath}/seenew?startPage=${news.pageNum-1}">上一页</a>
                    </c:when>
                    <c:when test="${news.pageNum-1<=0}">
                        <a href="${pageContext.request.contextPath}/seenew?startPage=1">上一页</a>
                    </c:when>
                </c:choose>
                <c:choose>
                    <c:when test="${news.pages==0}">
                        <a href="${pageContext.request.contextPath}/seenew?startPage=${news.pageNum}">下一页</a>
                    </c:when>
                    <c:when test="${news.pageNum+1<news.pages}">
                        <a href="${pageContext.request.contextPath}/seenew?startPage=${news.pageNum+1}">下一页</a>
                    </c:when>
                    <c:when test="${news.pageNum+1>=news.pages}">
                        <a href="${pageContext.request.contextPath}/seenew?startPage=${news.pageNum+1}">下一页</a>
                    </c:when>
                </c:choose>
                <c:choose>
                    <c:when test="${news.pages==0}">
                        <a href="${pageContext.request.contextPath}/seenew?startPage=${news.pageNum}">未 页</a>
                    </c:when>
                    <c:otherwise>
                        <a href="${pageContext.request.contextPath}/seenew?startPage=${news.pages}">未 页</a>
                    </c:otherwise>
                </c:choose>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<br/>
</body>
</html>